package com.example.ch5;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.Enumeration;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class TestInitParam extends HttpServlet {

    private static final long serialVersionUID = 1L;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp)
            throws ServletException, IOException {
        resp.setContentType("text/html");
        PrintWriter out = resp.getWriter();
        out.println("Test initial parameter<br/>");
        Enumeration<String> e = getServletConfig().getInitParameterNames();
        while (e.hasMoreElements()) {
            out.println("<br/>param name= " + e.nextElement() + "<br/>");
        }
        out.println("<br />");
        out.println("main email is "
                + getServletConfig().getInitParameter("mainEmail"));
        out.println("<br/>");
        out.println("admin email is "
                + getServletConfig().getInitParameter("adminEmail"));
        out.println("<br />This is context-initial-paramter : "
                + getServletContext().getInitParameter("adminEmail"));
    }

}
